/*  VisualGroup JavaScript prototype Classes, version draf
 *  (c) 2006 Bill Vison <vison_ruan@126.com>
 *
 *
/*--------------------------------------------------------------------------*/
Vsg.Dialog.Modeless = Class.create();

Vsg.Dialog.Modeless.prototype.initialize = function() {
	
	var url;
	var width = 450;
	var height = 300;
	var title = "Default Dialog Title";	
	
	// save window property
	var properties = new Array();
	
	// save window user data
	var userDatas = new Array();	

	this.setHeight = function(arg) {
		height = arg;
	}
	
	this.setWidth = function(arg) {
		width = arg;
	}
	
	this.setUrl = function(arg) {
		url = arg;
	}
	
	this.setTitle = function(arg) {
		title = arg;
	}
	
	this.setUserData = function(name , value) {
		var data = new Object();
		data.name = name;
		data.value = value;
		userDatas.push(data);
	}
	
	this.setWinFeature = function(arg0,arg1) {
		var feature = new Object();
		feature.name = arg0;
		feature.value = arg1;
		properties.push(feature);
	}

	this.setStatusbar = function($arg) {
		var $feature = new Object();
		$feature.name = "status";
		$feature.value = $arg;
		properties.push($feature);
	}
	
	this.setTitlebar = function($arg) {
		var $feature = new Object();
		$feature.name = "titlebar";
		$feature.value = $arg;
		properties.push($feature);

	}

	function getValue(name) {
		var value = null;
		for (index in properties) {
			if (properties[index].name == name) {
				value = properties[index].value;
			}
		}
		return value;
	}
	
	

	function show() {
		
		var windowX = Math.ceil( (window.screen.width  - width) / 2 );
		var windowY = Math.ceil( (window.screen.height - height) / 2 );
		
		
		var styleStr = "dialogWidth:"+width+"px;dialogHeight:"+height+"px";
		
		styleStr+=":dialogLeft:"+windowX+"px;dialogTop:"+windowY+"px";
		styleStr+=";center:1";
		
		// set edge
		var $edge = getValue("edge");
		if ($edge == null) {
			styleStr+=";edge:raised";
		} else {
			styleStr+=";edge:"+$edge;
		}
		
		var $unadorned = getValue("unadorned");
		if ($unadorned == null ) {
			styleStr+=";unadorned:no";
		} else {
			styleStr+=";unadorned:"+$unadorned;
		}
		

		var feaStatus = getValue("status");
		if (feaStatus == null) {
			styleStr+=";status:no";
		} else {
			styleStr+=";status:"+feaStatus;
		}
		
		
		var feaScrollbar = getValue("scroll");
		if (feaScrollbar == null) {
			styleStr+=";scroll:no";
		} else {
			styleStr+=";scroll:"+feaScrollbar;
		}
		
		var feaResizable = getValue("resizable");
		if (feaResizable == null) {
			styleStr+=";resizable:no";
		} else {
			styleStr+=";resizable:"+feaResizable;
		}

		var $returnValue = window.showModelessDialog(url,window,styleStr);
		
		window.popupUserData = userDatas;
		
		setPassArgment();
	}
	this.show = show;
	
	function setPassArgment() {
		var openArgs = new Array();
		
		// set properties
		var obj = new Object();
		obj.name = "title";
		obj.value = title;
		openArgs.push(obj);
		
		var widthObj = new Object();
		widthObj.name = "width";
		widthObj.value = width;
		openArgs.push(widthObj);

		var heightObj = new Object();
		heightObj.name = "height";
		heightObj.value = height;
		openArgs.push(heightObj);
		
		var urlObj = new Object();
		urlObj.name = "url";
		urlObj.value = url;
		openArgs.push(urlObj);
		
		window.popupArgument = openArgs;
	}	
	
}

